package cn.edu.hhtc.stsystem.security.domain;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 系统角色.
 * 
 * @author linyueqin
 * 
 */
@Entity
@Table(name = "SYS_ROLES")
public class SysRoles implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3103732221220017146L;

	@Id
	@Column(name = "ID")
	@SequenceGenerator(name = "SEQ_STORE", sequenceName = "SEQ_SYS_ROLES", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	private Long id;

	@Column(name = "NAME")
	private String name;

	@Column(name = "ENABLED")
	private Integer enabled;

	@Column(name = "IS_SYS")
	private Integer isSys;

	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinTable(name = "SYS_ROLES_AUTHORITIES", joinColumns = { @JoinColumn(name = "ROLE_ID") }, inverseJoinColumns = { @JoinColumn(name = "AUTHORITY_ID") })
	private Set<SysAuthorities> authorities = new LinkedHashSet<SysAuthorities>();

	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "roles")
	private Set<SysUsers> users = new LinkedHashSet<SysUsers>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getEnabled() {
		return enabled;
	}

	public void setEnabled(Integer enabled) {
		this.enabled = enabled;
	}

	public Integer getIsSys() {
		return isSys;
	}

	public void setIsSys(Integer isSys) {
		this.isSys = isSys;
	}

	public Set<SysUsers> getUsers() {
		return users;
	}

	public void setUsers(Set<SysUsers> users) {
		this.users = users;
	}

}
